<!doctype html>
<html>
<body>
<style id="target">
@font-face {
    font-family: TestFont;
    src: local(nonexistent), url(slow-ahem-loading.cgi);
}
</style>
<span id="testSpan">A</span>
<script>
if (window.testRunner)
    testRunner.waitUntilDone();

// Set the span's style and register a font ready listener in the same microtask so that font can't
// load before we've had a chance to register the listener.
document.getElementById('testSpan').style.fontFamily = "TestFont";

if (window.testRunner)
    document.fonts.ready.then(function() { testRunner.notifyDone(); });

var style = document.getElementById('target');
style.parentNode.removeChild(style);
document.body.offsetLeft;
document.body.appendChild(style);
</script>
</body>
</html>
